<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=3.0&ak=YdcyBdAMy2CPVhN4Eo0E4falnPff1Pna"></script>
    <title>单个地址解析</title>
    <style>
        body,html{
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
        }
        #container{
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
        #result{
            position: fixed;
            top: 10px;
            left: 10px;
            width: 250px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            background: #fff;
            box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
            border-radius: 7px;
            z-index: 99;
        }
    </style>
</head>
<body>
<div id='container'></div>
<div id='result'>江西省上饶市广信区第三小学</div>
<script>
    let addressReal = document.getElementById("result").innerText;
    var map = new BMapGL.Map('container');
    map.centerAndZoom(new BMapGL.Point(116.331398,39.897445), 12);
    map.enableScrollWheelZoom(true);
    //创建地址解析器实例
    var myGeo = new BMapGL.Geocoder();
    // 将地址解析结果显示在地图上，并调整地图视野
    console.log(addressReal)
    myGeo.getPoint(addressReal, function(point){
        if(point){
            map.centerAndZoom(point, 16);
            map.addOverlay(new BMapGL.Marker(point, {title: addressReal}))
        }else{
            alert('您选择的地址没有解析到结果！');
        }
    }, '北京市')
</script>
</body>
</html>